Skip to content

fix: locate external rb_binary main in runfiles on Windows - #446

Open
TrapsterDK wants to merge 1 commit into
bazel-contrib:mainfrom
TrapsterDK:fix/windows-binary-rlocation
Open

TrapsterDK wants to merge 1 commit into
bazel-contrib:mainfrom
TrapsterDK:fix/windows-binary-rlocation

Conversation

@TrapsterDK

Copy link
Copy Markdown
Contributor

Bug

On Windows, the batch launcher ran an rb_binary main from another repository (for example @bundle//bin:rake) through a path relative to the working directory. The launcher only worked from the default bazel run directory; started from anywhere else, it could not find the script. The shell launcher already resolves these through rlocation.

Fix

  • ruby/private/binary.bzl: binaries from other repositories are resolved with rlocation on every OS. Main-repository binaries on Windows keep the relative path (and the fallback added in fix: resolve rb_binary main scripts from any working directory #427).
  • ruby/private/utils.bzl: the batch rlocation function falls back to the nearest parent directory entry in the runfiles manifest, so files inside generated directories, such as the Bundler bin/private binstubs, are found.
  • ruby/private/binary/binary.cmd.tpl: runs the resolved !binary!.

Testing

  • New CI step runs the @bundle//bin:rake launcher from / on all OSes; this is the regression test.
  • bazel test //ruby/tests:all (10/10 passed) and bazel run //:buildifier.check locally on Linux, and the rake launcher from / on Linux.
  • I have no Windows machine, so the Windows path relies on the Windows CI job.

Assisted by Claude.

The Windows launcher ran binaries from other repositories, such as
`@bundle//bin:rake`, through a path relative to the working directory,
so the launcher only worked from the default `bazel run` directory.

Resolve those binaries with rlocation, like the shell launcher does.
The batch rlocation function now falls back to the nearest parent
directory entry in the manifest, which finds files inside generated
directories such as the Bundler `bin/private` binstubs.

CI runs the `@bundle//bin:rake` launcher from `/` on every OS.

Assisted-by: Claude
Comment thread ruby/private/utils.bzl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants